<?php
//传入新闻的id
$id=$_REQUEST["id"];

//取到旧新闻的图片、标题、内容
$conn=new mysqli("localhost","root","123456","htmlkeshe");
$conn->query("set names utf8");
$sql="SELECT * FROM news WHERE newsId=".$id.";";
$result=$conn->query($sql) or die(mysqli_error($conn));
if($result->num_rows>0) {
    while ($row = $result->fetch_assoc()) {
        $jpgurl=$row['newsPic'];
        $title=$row['title'];
        $txturl=$row['newsContent'];
    }
}
$conn->close();
?>



<html>
<head>

    <meta charset="utf-8">
    <title>新闻修改</title>
    <style type="text/css">
        @import "resource/css/newscha.css";
    </style>
    <script src="resource/js/safe.js"></script>
</head>
<body>
<div class="pan">
    <div class="back">
        <a href="Personal.php">返回<a>
    </div>
    <div class="main">
        <div class="photo">
            <p>原封面：</p>
            <img src="<?php echo $jpgurl?>"
        </div>
        <form action="newschangeDo.php?id=<?php echo $id?>" method="post" enctype="multipart/form-data">
            <div class="picture">
                <p>新闻封面选择</p>
                <input type="file" name="uppicture" id="uppicture" accept="image/*">
            </div>
            <div class="title">
                <p>新闻标题(不超过15个字符，且不能包含以下字符:/ \ : * " < > | ？):</p>
                <input type="text" name="title" id="title" maxlength="15" value="<?php echo $title?>" size="80" onkeyup="ValidateValue(this)">
            </div>
            <div class="lei">
                <p>游戏：</p>
                <select name="select" id="select" style="color:purple">
                    <option value="MHWI">MHW:I</option>
                    <option value="MHR">MHW:RISE</option>
                </select>
            </div>
            <div class="write">
                <p>新闻内容:</p>
                <textarea name="news" cols="110" rows="50" id="news"><?php readfile($txturl); ?></textarea>
            </div>
            <div class="submit">
                <input type="submit" value="更改" onclick="check()">
            </div>
        </form>
    </div>
</div>
<script type="text/javascript" src="resource/js/newscha.js"></script>
</body>
</html>
